Page({
  data: {  
    devicePosition: 'front'
  },
  onLoad(options) {  },
  takePhoto() {
    const ctx = wx.createCameraContext()
    ctx.takePhoto({
      quality: 'high',
      success: (res) => {
        this.setData({
          src: res.tempImagePath
        })
      }
    })
  },
  switchCamera() {
    const currentPosition = this.data.devicePosition;
    this.setData({
      devicePosition: currentPosition === 'back' ? 'front' : 'back'
    });
  }
})